package com.ruoyi.mp.service.impl;


import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.constant.CacheConstants;
import com.ruoyi.common.core.constant.MsgConstants;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.utils.*;
import com.ruoyi.common.core.utils.sms.AliyunSendSMS;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.db.domain.system.*;
import com.ruoyi.db.domain.web.dto.MpRegistForm;
import com.ruoyi.db.mapper.system.MpClientEarnsMapper;
import com.ruoyi.db.mapper.system.MpClientFriendsMapper;
import com.ruoyi.db.mapper.system.MpClientMapper;
import com.ruoyi.db.mapper.system.PcTeamConfigMapper;
import com.ruoyi.mp.service.IMpClientLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * 【商城用户】Service业务层处理
 *
 * @author ruoyi
 * @date 2022-07-22
 */
@Service
@Transactional(rollbackOn = Exception.class)
public class MpClientLoginServiceImpl implements IMpClientLoginService
{

    @Autowired
    private RedisService redisService;
    @Autowired
    private MpClientMapper mpClientMapper;
    @Autowired
    private MpClientFriendsMapper mpClientFriendsMapper;
    @Autowired
    private MpClientEarnsMapper mpClientEarnsMapper;
    @Autowired
    private PcTeamConfigMapper pcTeamConfigMapper;

    @Override
    public Boolean sendSmsByMobile(String mobile,Integer type) {
        if(StringUtils.isBlank(mobile)){
            throw new ServiceException("手机号不能为空");
        }
//
        MpClient sMpClient = new MpClient();
        sMpClient.setMobile(mobile);
        List<MpClient> sList = mpClientMapper.selectMpClientList(sMpClient);
       if(type==1){
           if(sList.size()>0){
               throw new ServiceException("手机号已注册");
           }
           if(redisService.hasKey("REG"+mobile)){
               throw new ServiceException(MsgConstants.SMS_REPEAT_SEND);
           }
           String code = SendSmsUtils.createRandom(true,6);
           boolean isSend = AliyunSendSMS.sendSms(mobile,code);
           if(isSend){
               redisService.setCacheObject("REG"+mobile,code, CacheConstants.EXPIRATION_SMS, TimeUnit.MINUTES);
               return true;
           }else{
               return false;
           }
       }
       if(type==2){
           if(sList.size()<=0){
               throw new ServiceException("手机号未注册");
           }
           if(redisService.hasKey("RES"+mobile)){
               throw new ServiceException(MsgConstants.SMS_REPEAT_SEND);
           }
           String code = SendSmsUtils.createRandom(true,6);
           boolean isSend = AliyunSendSMS.sendSms(mobile,code);
           if(isSend){
               redisService.setCacheObject("RES"+mobile,code, CacheConstants.EXPIRATION_SMS, TimeUnit.MINUTES);
               return true;
           }else{
               return false;
           }
       }
       if(type==3){
           if(sList.size()<=0){
               throw new ServiceException("手机号未注册");
           }
           if(redisService.hasKey("PAY"+mobile)){
               throw new ServiceException(MsgConstants.SMS_REPEAT_SEND);
           }
           String code = SendSmsUtils.createRandom(true,6);
           boolean isSend = AliyunSendSMS.sendSms(mobile,code);
           if(isSend){
               redisService.setCacheObject("PAY"+mobile,code, CacheConstants.EXPIRATION_SMS, TimeUnit.MINUTES);
               return true;
           }else{
               return false;
           }
       }
        if(type==4){
            if(redisService.hasKey("BANK"+mobile)){
                throw new ServiceException(MsgConstants.SMS_REPEAT_SEND);
            }
            String code = SendSmsUtils.createRandom(true,6);
            boolean isSend = AliyunSendSMS.sendSms(mobile,code);
            if(isSend){
                redisService.setCacheObject("BANK"+mobile,code, CacheConstants.EXPIRATION_SMS, TimeUnit.MINUTES);
                return true;
            }else{
                return false;
            }
        }
        if(type==5){
            if(redisService.hasKey("UPDP"+mobile)){
                throw new ServiceException(MsgConstants.SMS_REPEAT_SEND);
            }
            String code = SendSmsUtils.createRandom(true,6);
            boolean isSend = AliyunSendSMS.sendSms(mobile,code);
            if(isSend){
                redisService.setCacheObject("UPDP"+mobile,code, CacheConstants.EXPIRATION_SMS, TimeUnit.MINUTES);
                return true;
            }else{
                return false;
            }
        }
        if(type==6){
            if(redisService.hasKey("UPDM"+mobile)){
                throw new ServiceException(MsgConstants.SMS_REPEAT_SEND);
            }
            String code = SendSmsUtils.createRandom(true,6);
            boolean isSend = AliyunSendSMS.sendSms(mobile,code);
            if(isSend){
                redisService.setCacheObject("UPDM"+mobile,code, CacheConstants.EXPIRATION_SMS, TimeUnit.MINUTES);
                return true;
            }else{
                return false;
            }
        }
       return false;
    }

    @Override
    public synchronized void  clientRegister(MpRegistForm form) {
        String mobile = form.getMobile();
        String code = form.getCode();
        if(StringUtils.isBlank(mobile)){
            throw new ServiceException("手机号不能为空");
        }

        MpClient sMpClient = new MpClient();
        sMpClient.setMobile(mobile);
        List<MpClient> sList = mpClientMapper.selectMpClientList(sMpClient);
        if(sList.size()>0){
            throw new ServiceException("手机号已注册");
        }
        //验证码验证
        if(StringUtils.isBlank(code)){
            throw new ServiceException("验证码不能为空");
        }
        if(!redisService.hasKey("REG"+mobile)||!redisService.getCacheObject("REG"+mobile).toString()
                .equals(code)){
            throw new ServiceException("验证码错误");
        }
        //密码验证
        String password = form.getPassword();
        if (StringUtils.isBlank(password)){
            throw new ServiceException("密码不能为空");
        }
        if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
                || password.length() > UserConstants.PASSWORD_MAX_LENGTH)
        {
            throw new ServiceException("密码长度必须在5到20个字符之间");
        }
        String rPwd = form.getrPassword();
        if(StringUtils.isBlank(rPwd)){
            throw new ServiceException("确认密码不能为空");
        }
        if(!password.equals(rPwd)){
            throw new ServiceException("两次密码不一致");
        }
        //邀请码验证
        String inviteCode = form.getInviteCode();
        if(StringUtils.isBlank(inviteCode)){
            throw new ServiceException("请输入邀请码");
        }
        MpClient parent = new MpClient();
        parent.setInviteCode(inviteCode);
        List<MpClient> parents = mpClientMapper.selectMpClientList(parent);
        if(parents.size()<=0){
            throw new ServiceException("邀请码无效");
        }
        //注册成功,插入用户数据,插入用户上级数据,生成用户邀请码
        String entryPwd = EncryptAesUtil.encrypt(password);
        MpClient client = new MpClient();
        client.setPassword(entryPwd);
        client.setRegistTime(new Date());
        client.setMobile(mobile);
        client.setStatus("1");
        client.setIsVirtual(0);
        client.setGoldBeanBalance(new BigDecimal(0));
        client.setSilverBeanBalance(new BigDecimal(0));
        client.setGoldTransferLimit(new BigDecimal(0));
        client.setSilverTransferLimit(new BigDecimal(0));
        client.setMyEarns("0");
        client.setIsInstitutions(0);
        if(mpClientMapper.insertMpClient(client)>0){
            String inviteCodeMy = ShareCodeUtil.toSerialCode(client.getClientId());
            client.setInviteCode(inviteCodeMy);
            if(mpClientMapper.updateMpClient(client)>0){
                //这里设置文本内容
                String text = "http://www.zaoshanghao.net/#/pages/logins/register?inviteCode="+inviteCodeMy+"";
                // 嵌入二维码的图片路径  可以不写
                String logoPath = "";
                // 生成的二维码的路径及名称
                String destPath = "/usr/local/code";
                //生成二维码
                try {
                    String path = QRCodeUtils.encode(text, logoPath, destPath, true);
                    String url = "http://img.zaoshanghao.net/statics/"+path;
                    client.setInviteUrl(url);
                    mpClientMapper.updateMpClient(client);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                MpClientFriends friends = new MpClientFriends();
                friends.setClienId(client.getClientId());
                friends.setpClientId(parents.get(0).getClientId());
                if(mpClientFriendsMapper.insertMpClientFriends(friends)<=0){
                    throw new ServiceException("注册失败,请稍后再试");
                }
            }else{
                throw new ServiceException("注册失败,请稍后再试");
            }
        }else{
            throw new ServiceException("注册失败,请稍后再试");
        }

    }

    @Override
    public MpClient clientLogin(MpRegistForm form) {
        String mobile = form.getMobile();
        String password = form.getPassword();
        if(StringUtils.isBlank(mobile)){
            throw new ServiceException("手机号不能为空");
        }

        MpClient sMpClient = new MpClient();
        sMpClient.setMobile(mobile);
        List<MpClient> sList = mpClientMapper.selectMpClientList(sMpClient);
        if(sList.size()<=0){
            throw new ServiceException("手机号不存在");
        }
        String pwdReal =  sList.get(0).getPassword();
        String entryPwd = EncryptAesUtil.encrypt(password);
        if(entryPwd==null||!pwdReal.equals(entryPwd)){
            throw new ServiceException("密码错误");
        }
        return sList.get(0);

    }

    @Override
    public void passwordReset(MpRegistForm form) {
        String mobile = form.getMobile();
        String password = form.getPassword();
        if(StringUtils.isBlank(mobile)){
            throw new ServiceException("手机号不能为空");
        }

        MpClient sMpClient = new MpClient();
        sMpClient.setMobile(mobile);
        List<MpClient> sList = mpClientMapper.selectMpClientList(sMpClient);
        if(sList.size()<=0){
            throw new ServiceException("手机号不存在");
        }
        MpClient client =  sList.get(0);
        //密码验证
        if (StringUtils.isBlank(password)){
            throw new ServiceException("密码不能为空");
        }
        if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
                || password.length() > UserConstants.PASSWORD_MAX_LENGTH)
        {
            throw new ServiceException("密码长度必须在5到20个字符之间");
        }
        //验证码验证
        String code = form.getCode();
        if(StringUtils.isBlank(code)){
            throw new ServiceException("验证码不能为空");
        }
        if(!redisService.hasKey("RES"+mobile)||!redisService.getCacheObject("RES"+mobile).toString()
                .equals(code)){
            throw new ServiceException("验证码错误");
        }
        String entryPwd = EncryptAesUtil.encrypt(password);
        client.setPassword(entryPwd);
        mpClientMapper.updateMpClient(client);
    }

    @Override
    public Map<String, Object> getEarnsReport(MpClient client) {
        Map<String,Object> map = new HashMap<>();
        MpClientEarns sEarns = new MpClientEarns();
        sEarns.setEarnsType(1);
        sEarns.setClientId(client.getClientId());
        List<MpClientEarns> earns = mpClientEarnsMapper.selectMpClientEarnsList(sEarns);
        BigDecimal firstAmount = earns.stream().map( MpClientEarns::getClientEarns ).reduce(BigDecimal.ZERO, BigDecimal::add); //BigDecimal类型
        MpClientEarns sEarns2 = new MpClientEarns();
        sEarns2.setEarnsType(2);
        sEarns2.setClientId(client.getClientId());
        List<MpClientEarns> earns2 = mpClientEarnsMapper.selectMpClientEarnsList(sEarns2);
        BigDecimal secondAmount = earns2.stream().map( MpClientEarns::getClientEarns ).reduce(BigDecimal.ZERO, BigDecimal::add); //BigDecimal类型
        BigDecimal totalClientAmount = firstAmount.add(secondAmount);
        map.put("pushAmount",totalClientAmount);
        List<BigDecimal> pushList =new ArrayList<>();
        List<String> timeList = new ArrayList<>();
        List<BigDecimal> myList = new ArrayList<>();
        for (int i = 4; i >= 0; i--) {
            //获取今天开始时间和结束时间
            String sendSta =null;
            String sendEnd =null;
            LocalDateTime todayStart = null;
            LocalDateTime todayEnd = null;
            todayStart = LocalDateTime.of(LocalDate.now().plusDays(-i), LocalTime.MIN);//当天零点
            todayEnd = LocalDateTime.of(LocalDate.now().plusDays(-i), LocalTime.MAX);//当天零点
            sendSta= todayStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            sendEnd= todayEnd.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
            timeList.add(todayStart.format(DateTimeFormatter.ofPattern("MM-dd")));
            MpClientEarns sEarnsToday = new MpClientEarns();
            sEarnsToday.setEarnsType(1);
            sEarnsToday.setClientId(client.getClientId());
            sEarnsToday.setStartTime(sendSta);
            sEarnsToday.setEndTime(sendEnd);
            List<MpClientEarns> earnsToday = mpClientEarnsMapper.selectMpClientEarnsListByTime(sEarnsToday);
            BigDecimal firstAmountToday = earnsToday.stream().map( MpClientEarns::getClientEarns ).reduce(BigDecimal.ZERO, BigDecimal::add); //BigDecimal类型

            MpClientEarns sEarnsToday2 = new MpClientEarns();
            sEarnsToday2.setEarnsType(2);
            sEarnsToday2.setClientId(client.getClientId());
            sEarnsToday2.setStartTime(sendSta);
            sEarnsToday2.setEndTime(sendEnd);
            List<MpClientEarns> earnsToday2 = mpClientEarnsMapper.selectMpClientEarnsListByTime(sEarnsToday2);
            BigDecimal secondAmountToday = earnsToday2.stream().map( MpClientEarns::getClientEarns ).reduce(BigDecimal.ZERO, BigDecimal::add); //BigDecimal类型

            BigDecimal todayAmount =firstAmountToday.add(secondAmountToday);
            pushList.add(todayAmount);
            myList.add(todayAmount);
        }
        map.put("pushList",pushList);
        map.put("timeList",timeList);
        map.put("today",pushList.get(4));
        Map<String,Object> teamMap = new HashMap<>();
        Map<String,Object> myMap = new HashMap<>();
        List<BigDecimal> teamList = new ArrayList<>();
        myMap.put("timeList",timeList);
        if(client.getTeamConfigId()!=null&&client.getTeamConfigId()!=0){
            MpClientEarns sEarnsTeam = new MpClientEarns();
            sEarnsTeam.setEarnsType(3);
            sEarnsTeam.setClientId(client.getClientId());
            List<MpClientEarns> earnsTeam = mpClientEarnsMapper.selectMpClientEarnsList(sEarnsTeam);
            BigDecimal teamAmount = earnsTeam.stream().map( MpClientEarns::getClientEarns ).reduce(BigDecimal.ZERO, BigDecimal::add); //BigDecimal类型
            teamMap.put("teamAmount",teamAmount);
            myMap.put("myAmount",totalClientAmount.add(teamAmount));
            int k=0;
            for (int i = 4; i >= 0; i--) {
                //获取今天开始时间和结束时间
                String sendSta =null;
                String sendEnd =null;
                LocalDateTime todayStart = null;
                LocalDateTime todayEnd = null;
                todayStart = LocalDateTime.of(LocalDate.now().plusDays(-i), LocalTime.MIN);//当天零点
                todayEnd = LocalDateTime.of(LocalDate.now().plusDays(-i), LocalTime.MAX);//当天零点
                sendSta= todayStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                sendEnd= todayEnd.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));

                MpClientEarns sEarnsTodayTeam = new MpClientEarns();
                sEarnsTodayTeam.setEarnsType(3);
                sEarnsTodayTeam.setClientId(client.getClientId());
                sEarnsTodayTeam.setStartTime(sendSta);
                sEarnsTodayTeam.setEndTime(sendEnd);
                List<MpClientEarns> earnsTodayTeam= mpClientEarnsMapper.selectMpClientEarnsListByTime(sEarnsTodayTeam);
                BigDecimal teamAmountToday = earnsTodayTeam.stream().map( MpClientEarns::getClientEarns ).reduce(BigDecimal.ZERO, BigDecimal::add); //BigDecimal类型
                teamList.add(teamAmountToday);
                myList.set(k,myList.get(k).add(teamAmountToday));
                k++;
            }
            teamMap.put("teamList",teamList);
            teamMap.put("timeList",timeList);
            teamMap.put("today",teamList.get(4));
        }else {
            myMap.put("myAmount",totalClientAmount);
        }
        myMap.put("myList",myList);
        myMap.put("today",myList.get(4));
        Map<String,Object> allMap =  new HashMap<>();
        allMap.put("pushMap",map);
        allMap.put("teamMap",teamMap);
        allMap.put("myMap",myMap);
        return allMap;
    }

    @Override
    public List<MpClient> getEarnsMyFriend(MpClient client,Integer type,Integer pageNum,Integer pageSize) {
        if(type==1){
            MpClientFriends mpFriends = new MpClientFriends();
            mpFriends.setpClientId(client.getClientId());
            List<MpClientFriends> fList = mpClientFriendsMapper.selectMpClientFriendsList(mpFriends);
            if(fList==null||fList.size()==0){
                return new ArrayList<>();
            }
            List<Long> fIds = fList.stream().map(e->e.getClienId()).collect(Collectors.toList());
            if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
                PageHelper.startPage(pageNum, pageSize);
            }
            List<MpClient> first = mpClientMapper.selectMpClientListByIds(new MpClient(),fIds);
            for (MpClient client1: first){
                MpClientEarns mpClientEarns = new MpClientEarns();
                mpClientEarns.setClientId(client.getClientId());
                mpClientEarns.setChildId(client1.getClientId());
                List<MpClientEarns> allEarns = mpClientEarnsMapper.selectMpClientEarnsList(mpClientEarns);
                BigDecimal earns = allEarns.stream().filter(e->e.getClientEarns()!=null).collect(Collectors.toList()).stream().map( MpClientEarns::getClientEarns ).reduce(BigDecimal.ZERO, BigDecimal::add); //BigDecimal类型
                client1.setEarnsMyFriend(earns);
            }
            return first;
        }
        if(type==2){
            MpClientFriends mpFriends = new MpClientFriends();
            mpFriends.setpClientId(client.getClientId());
            List<MpClientFriends> fList = mpClientFriendsMapper.selectMpClientFriendsList(mpFriends);
            if(fList==null||fList.size()==0){
                return new ArrayList<>();
            }
            List<MpClientFriends> sList = new ArrayList<>();
            for (MpClientFriends fr: fList) {
                MpClientFriends mppFriends = new MpClientFriends();
                mppFriends.setpClientId(fr.getClienId());
                List<MpClientFriends> ffList = mpClientFriendsMapper.selectMpClientFriendsList(mppFriends);
                sList.addAll(ffList);
            }
            if(sList.size()==0){
                return new ArrayList<>();
            }
            List<Long> sIds = sList.stream().map(e->e.getClienId()).collect(Collectors.toList());
            if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
                PageHelper.startPage(pageNum, pageSize);
            }
            List<MpClient> second = mpClientMapper.selectMpClientListByIds(new MpClient(),sIds);
            for (MpClient client1: second){
                MpClientEarns mpClientEarns = new MpClientEarns();
                mpClientEarns.setClientId(client.getClientId());
                mpClientEarns.setChildId(client1.getClientId());
                List<MpClientEarns> allEarns = mpClientEarnsMapper.selectMpClientEarnsList(mpClientEarns);
                BigDecimal earns = allEarns.stream().filter(e->e.getClientEarns()!=null).collect(Collectors.toList()).stream().map( MpClientEarns::getClientEarns ).reduce(BigDecimal.ZERO, BigDecimal::add); //BigDecimal类型
                client1.setEarnsMyFriend(earns);
            }
            return second;
        }
        if(type==3){
            MpClient sClinet = mpClientMapper.selectMpClientByClientId(client.getClientId());
            if(sClinet==null){
                return new ArrayList<>();
            }
            MpClientFriends mpFriends = new MpClientFriends();
            mpFriends.setpClientId(client.getClientId());
            List<MpClientFriends> fList = mpClientFriendsMapper.selectMpClientFriendsList(mpFriends);
            if(fList==null||fList.size()==0){
                return new ArrayList<>();
            }
            List<Long> fIds = fList.stream().map(e->e.getClienId()).collect(Collectors.toList());

            List<MpClientFriends> sList = new ArrayList<>();
            for (MpClientFriends fr: fList) {
                MpClientFriends mppFriends = new MpClientFriends();
                mppFriends.setpClientId(fr.getClienId());
                List<MpClientFriends> ffList = mpClientFriendsMapper.selectMpClientFriendsList(mppFriends);
                sList.addAll(ffList);
            }
            if(sList.size()==0){
                return new ArrayList<>();
            }
            List<Long> sIds = sList.stream().map(e->e.getClienId()).collect(Collectors.toList());
            List<Long> myIds = new ArrayList<>();
            myIds.addAll(fIds);
            myIds.addAll(sIds);

            List<Long> allChildIdList = getUserIds(fList);
//            List<Long> reList = allChildIdList.stream().filter(e->!myIds.contains(e)).collect(Collectors.toList());
            List<Long> reList = allChildIdList;
            if(reList==null||reList.size()==0){
                return new ArrayList<>();
            }
            if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {
                PageHelper.startPage(pageNum, pageSize);
            }
            List<MpClient> team = mpClientMapper.selectMpClientListByIds(new MpClient(),reList);
            for (MpClient client1: team){
                MpClientEarns mpClientEarns = new MpClientEarns();
                mpClientEarns.setClientId(client.getClientId());
                mpClientEarns.setChildId(client1.getClientId());
                List<MpClientEarns> allEarns = mpClientEarnsMapper.selectMpClientEarnsList(mpClientEarns);
                BigDecimal earns = allEarns.stream().filter(e->e.getClientEarns()!=null).collect(Collectors.toList()).stream().map( MpClientEarns::getClientEarns ).reduce(BigDecimal.ZERO, BigDecimal::add); //BigDecimal类型
                client1.setEarnsMyFriend(earns);
            }
            return team;
        }
        return new ArrayList<>();
    }
    //递归出所有用户下级id
    private List<Long> getUserIds(List<MpClientFriends> userIdlist){
        List<Long> ids = new ArrayList<>();
        if(userIdlist!=null && userIdlist.size()>0){
            for(MpClientFriends vo:userIdlist){
                ids.add(vo.getClienId());
                MpClientFriends parentF = new MpClientFriends();
                parentF.setpClientId(vo.getClienId());
                List<MpClientFriends> childs =mpClientFriendsMapper.selectMpClientFriendsList(parentF);
                ids.addAll(getUserIds(childs));
            }
        }
        return ids;
    }
    @Override
    public PcTeamConfig getTeam(MpClient client) {
        if(client.getTeamConfigId()!=null&&client.getTeamConfigId()!=0){
            PcTeamConfig config = pcTeamConfigMapper.selectPcTeamConfigById(client.getTeamConfigId());
            if(config.getTeamLevel().equals("v1")){
                PcTeamConfig config1 = new PcTeamConfig();
                config1.setTeamLevel("v2");
                List<PcTeamConfig> list = pcTeamConfigMapper.selectPcTeamConfigList(config1);
                return list.get(0);
            }
            if(config.getTeamLevel().equals("v2")){
                PcTeamConfig config1 = new PcTeamConfig();
                config1.setTeamLevel("v3");
                List<PcTeamConfig> list = pcTeamConfigMapper.selectPcTeamConfigList(config1);
                return list.get(0);
            }
        }
        PcTeamConfig config1 = new PcTeamConfig();
        config1.setTeamLevel("v1");
        List<PcTeamConfig> list = pcTeamConfigMapper.selectPcTeamConfigList(config1);
        return list.get(0);
    }

}
